feat: support typescript linting and type checking #474
+1,019
−264
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support to linting and type checking typescript projects.
Notes:
As part of this, I upgraded eslint to v8. This is not the latest, the latest v9 requires a new structure for eslint configs, and would mean that we'd have to pass a flag to use the old config in our projects. I plan to write an RFC for the next steps for the configs (proposing to use shared configs and using the CLI tool only as a helper for installing these configs) and I will look at upgrading eslint to v9 as part of that.
I added a check to run
tsc --noEmit
to do a type check on Typescript projects - this is an implicit test that runs wheneever it seems atsconfig.json
in the root of the project. I think that if a consumer is using TS then they should make sure it compiles, they're free to disable rules or change the config, but it should always compile.For this to work without a module resolution, we also need to bump this outdated version of TS in app-shell: fix: bump typescript version used in app shell app-platform#885
Right now, it shows the below warnning since hte eslint plugin was not updated to support the latest version of TS but that's not an issue
Testing
I tested this works with
route-manager-app
(TS),data-entry-beta
(JS),data-visualiser
(JS),maintenance-app-beta
(TS)Followups:
implements https://dhis2.atlassian.net/browse/LIBS-696